package ar.edu.unicen.exa.oop.bbquery.model.forum.topic;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * A topic is a particular theme that will be discused in a particular forum
 * Some topics can be composite (a topic with subtopics).
 * 
 * @author nicolas
 * 
 */
@Entity
public abstract class Topic implements Serializable {

	private static Logger log = LoggerFactory.getLogger(Topic.class);

	private static final long serialVersionUID = -4097671858058369215L;

	private String description;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Integer getId() {
		return _topicNumber;
	}

	private Integer _topicNumber;

	public Topic(String description, Integer topicNmb) {
		log.info("Creating Topic");
		setDescription(description);
		setId(topicNmb);
	}

	/*
	 * public abstract void setTitle(String title);
	 * 
	 * public abstract String getTitle();
	 */

	void setDescription(String description) {
		this.description = description;
	}

	public String getDescription() {
		return description;
	}

	public void setId(Integer topicNumber) {
		this._topicNumber = topicNumber;
	}

	/*
	 * private class PostIterator implements Iterator<Post> {
	 * 
	 * private final Stack<Post> posts = new Stack<Post>();
	 * 
	 * public PostIterator() {
	 * 
	 * Post myPost = Topic.this.getOpeningPost(); if (myPost != null) {
	 * this.posts.push(myPost); } }
	 * 
	 * @Override public boolean hasNext() { return !posts.isEmpty(); }
	 * 
	 * @Override public Post next() { if (!hasNext()) throw new
	 * NoSuchElementException("No more posts"); Post p = posts.pop(); List<Post>
	 * lpost = p.getReplies(); if (!lpost.isEmpty()) posts.addAll(lpost); return
	 * p; }
	 * 
	 * @Override public void remove() { posts.pop(); }
	 * 
	 * }
	 * 
	 * public Iterator<Post> iterator() { return new PostIterator(); }
	 */

}
